#include <iostream>
#include <algorithm>

using namespace std;

const int N = 50010;
int n, m;
int p[N], cnt[N];
int times;

int find(int x){
    if(p[x] != x) p[x] = find(p[x]);
    return p[x];
}

int main(){
    while(true){
        
        scanf("%d%d", &n, &m);
        if(n + m == 0) return 0;
        times++;
        int a, b;
        for(int i = 1; i <= n; i ++)
        {
            p[i] =i;
        }
        while(m --){
            scanf("%d%d", &a, &b);
            a = find(a), b = find(b);
            if(a!= b)
            {
                p[a] = b;
            }
        }

        int res = 0;
        for(int i = 1; i <= n; i ++)
            if(p[i]== i) res ++;
        printf("Case %d: %d\n", times, res);

    }
    

}